package com.g5.edu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.g5.edu.model.DfNewsInfo;
import com.g5.edu.mapper.DfNewsInfoMapper;
import com.g5.edu.service.IDfNewsInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 新闻表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2021-10-29
 */
@Service
public class DfNewsInfoServiceImpl extends ServiceImpl<DfNewsInfoMapper, DfNewsInfo> implements IDfNewsInfoService {



    @Autowired(required = false)
    private DfNewsInfoMapper dfNewsInfoMapper;

    @Override
    public PageInfo<DfNewsInfo> getNews(Integer pageNum, Integer pageSize,Integer page) {
        PageHelper.startPage(pageNum,pageSize);
        /*
        List<DfNewsInfo> newsData = redisTemplate.opsForValue().get("news");
        if (newsData==null) {
            newsData=dfNewsInfoMapper.selectList(null);
            redisTemplate.opsForValue().set("news",newsData);
        }
        */
        QueryWrapper<DfNewsInfo> query=new QueryWrapper<>();
        query.eq("news_type",page);
        List<DfNewsInfo> newsData = dfNewsInfoMapper.selectList(query);

        return new PageInfo<>(newsData);
    }

}
